﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/AdminTemplate.Master" AutoEventWireup="true"
    CodeBehind="ManageLocations.aspx.cs" Inherits="RealtorsPortal.ManageLocations" %>
    
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Locations Management</title>
    <script type="text/javascript" language="javascript">
        jQuery(document).ready(function () {
            $("#navheadAdmin").addClass("selected");
            $("#mnuAdmin").css("display", "block");
            $(".submenu li a[title='Manage locations']").css({ "color": "#fff", "background": "#222", "border": "1px solid #333" });

            jQuery("#contentArea").tabs(); //tab view   
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        LOCATIONS MANAGEMENT</h1>
    ______________________________________________________________________________________________
    <div id="contentArea">
        <ul>
            <li><a href="#tab1">Manage countries</a></li>
            <li><a href="#tab2">Manage regions</a></li>
            <li><a href="#tab3">Manage cities</a></li>
            <li><a href="#tab4">Manage districts</a></li>
        </ul>
        <div id="tab1">
            <fieldset>
                <h2>
                    Add a new country</h2>
                <div class="input_field">
                    <label>
                        Country name:
                    </label>
                    <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
                </div>
                <div class="input_field no_margin_bottom">
                    <label>
                        &nbsp;</label>
                    <asp:Button ID="btnAddCountry" runat="server" Text="ADD" CssClass="submit" 
                        onclick="btnAddCountry_Click" />
                    <input class="submit" type="reset" value="RESET" />
                </div>
            </fieldset>
            <h2>
                Countries List</h2>
            <%--
            <table cellspacing="0" cellpadding="0" border="0" id="tblAccounts">
                <!-- Table -->
                <thead>
                    <tr>
                        <th>
                            <input type="checkbox" class="checkall" />
                        </th>
                        <th>
                            Id
                        </th>
                        <th>
                            Country name
                        </th>
                        <th>
                            Actions
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="rptContries" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:CheckBox ID="chkDelete" runat="server" />
                                </td>
                                <td>
                                    <asp:Label ID="lblUserId" runat="server" Text='<%# Eval("CountryId") %> '></asp:Label>
                                </td>
                                <td>
                                    <%# Eval("CountryName")%>
                                </td>
                                <td>
                                    <a href="#" class="browsebtn" param="<%# Eval("CountryId")%>">
                                        <img src="assets/b_browse.png" alt="Browse" title="Browse" /></a> <a href="#" class="editbtn"
                                            param="<%# Eval("CountryId")%>">
                                            <img src="assets/b_edit.png" alt="Edit" title="Edit" /></a> <a href="#">
                                                <img src="assets/b_drop.png" alt="Remove" title="Remove" />
                                </td>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        --%>
            
            <asp:GridView ID="grvCountry" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataKeyNames="CountryId" PageSize="5" 
                onpageindexchanging="grvCountry_PageIndexChanging" 
                onrowcancelingedit="grvCountry_RowCancelingEdit" 
                onrowcommand="grvCountry_RowCommand" onrowdeleting="grvCountry_RowDeleting" onrowediting="grvCountry_RowEditing" OnRowDataBound="grvCountry_RowDataBound" OnRowUpdating="grvCountry_RowUpdating" Width="100%">
               <HeaderStyle CssClass="header_gridview" />
               <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="Id">
                        <ItemTemplate>
                            <%#Eval ("CountryId") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Country Name">
                        <ItemTemplate>
                            <%# Eval("CountryName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="etxtCountryName" runat="server" Text='<%# Bind("CountryName")%>' Visible="true"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Actions">
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbtnUpdateCountryTab" runat="server" CommandName="UpdateComponent" 
                                ValidationGroup="update" CausesValidation="True"
                                Text="Update" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Update</asp:LinkButton>
                            <asp:LinkButton ID="lbtnCancelCountryTab" runat="server" CommandName="CancelCompoent" 
                                ValidationGroup="cancel"  CausesValidation="false"
                                Text="Cancel" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Cancel</asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex")%>'>
                                <asp:Image ID="ibtnEdit" runat="server" ImageUrl="assets/b_edit.png"/></asp:LinkButton>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>
                                <asp:Image ID="ibtnDelete" runat="server" ImageUrl="assets/action_delete.png"/></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label1" runat="server" Text="Display: ">Display:</asp:Label>
            <asp:DropDownList ID="ddlPageSizeCountry" runat="server" AutoPostBack="true"
                onselectedindexchanged="ddlPageSizeCountry_SelectedIndexChanged1">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div id="tab2">
            <fieldset>
                <h2>
                    Add a new region</h2>
                <div class="input_field">
                    <label>
                        Country:</label>
                    <asp:DropDownList ID="ddlCountry" runat="server" Width="215px">
                     <asp:ListItem Text = "--Select Country--" Value = ""></asp:ListItem>
                    </asp:DropDownList>
                </div>
                <div class="input_field">
                    <label>
                        Region name:       
                    </label>
                    <asp:TextBox ID="txtRegion" runat="server"></asp:TextBox>
                </div>
                <div class="input_field no_margin_bottom">
                <label>
                        &nbsp;</label>
                    <asp:Button ID="btnAddRegion" runat="server" Text="ADD" CssClass="submit" />
                    <input class="submit" type="reset" value="RESET" />
                </div>
            </fieldset>

            <h2>Regions List</h2>
            <asp:GridView ID="grvRegion" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataKeyNames="RegionId" 
                onpageindexchanging="grvRegion_PageIndexChanging" 
                onrowcancelingedit="grvRegion_RowCancelingEdit" 
                onrowcommand="grvRegion_RowCommand" onrowdeleting="grvRegion_RowDeleting" 
                onrowediting="grvRegion_RowEditing" PageSize="5" OnRowDataBound="grvRegion_RowDataBound" OnRowUpdating="grvRegion_RowUpdating" Width="100%" >
                <HeaderStyle CssClass="header_gridview" />
                <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="Id">
                        <ItemTemplate>
                            <%#Eval ("RegionId") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Region Name">
                        <ItemTemplate>
                            <%#Eval ("RegionName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="etxtRegionName" runat="server" Text='<%# Bind("RegionName")%>' Visible="true"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Country Name">
                        <ItemTemplate>
                            <%# Eval("CountryName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="extddlCountryName" runat="server" DataTextField="CountryName" DataValueField="CountryId" ></asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Actions">
                        
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbtnUpdateRegionTab" runat="server" CommandName="UpdateComponent" 
                                ValidationGroup="update" CausesValidation="True"
                                Text="Update" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Update</asp:LinkButton>
                            <asp:LinkButton ID="lbtnCancelRegionTab" runat="server" CommandName="CancelCompoent" 
                                ValidationGroup="cancel"  CausesValidation="false"
                                Text="Cancel" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Cancel</asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Edit"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex")%>'>
                                <asp:Image ID="ibtnEdit" runat="server" ImageUrl="assets/b_edit.png"/></asp:LinkButton>
                            <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Delete"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>
                                <asp:Image ID="ibtnDelete" runat="server" ImageUrl="assets/action_delete.png"/></asp:LinkButton>
                        </ItemTemplate>
                        
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label2" runat="server" Text="Display: ">Display:</asp:Label>
            <asp:DropDownList ID="ddlPageSizeRegion" runat="server" AutoPostBack="true">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div id="tab3">
            <fieldset>
                <h2>Add a new city</h2>
                    <div class="input_field"><label>Country:</label>
                    <asp:DropDownList ID="ddlCountryForCity" runat="server" Width="215px" OnSelectedIndexChanged="ddlCountryForCity_SelectedIndexChanged1" AutoPostBack="true">
                            </asp:DropDownList></div>
                    <div class="input_field"><label>Region:</label>
                    <asp:DropDownList ID="ddlRegion" runat="server" Width="215px">
                            </asp:DropDownList></div>
                <div class="input_field">
                    <label>City name:</label>
                    <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
                </div>
                <div class="input_field no_margin_bottom">
                    <label>&nbsp;</label>
                    <asp:Button ID="btnAddCity" runat="server" Text="ADD" CssClass="submit" 
                        onclick="btnAddCity_Click" />
                    <input class="submit" type="reset" value="RESET" />
                </div>
            </fieldset>
            <h2>Cities List</h2>
            <asp:GridView ID="grvCity" runat="server" AutoGenerateColumns="False" 
                AllowPaging="True" DataKeyNames="CityId" PageSize="5" OnRowCancelingEdit="grvCity_RowCancelingEdit1" OnRowDataBound="grvCity_RowDataBound" OnRowDeleting="grvCity_RowDeleting1" OnRowEditing="grvCity_RowEditing1" OnRowUpdating="grvCity_RowUpdating" OnRowCommand="grvCity_RowCommand1" Width="100%" >
                <HeaderStyle CssClass="header_gridview"/>
                <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="Id">
                        <ItemTemplate>
                            <%#Eval ("CityId") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="City Name">
                        <ItemTemplate>
                            <%#Eval ("CityName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="extxtCityName" runat="server" Text='<%# Bind("CityName")%>' Visible="true"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Region Name">
                        <ItemTemplate>
                            <%#Eval("RegionName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="extddlRegionName" runat="server" DataTextField="RegionName" DataValueField="RegionId" ></asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Actions">
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbtnUpdateCityTab" runat="server" CommandName="UpdateComponent" 
                                ValidationGroup="update" CausesValidation="True"
                                Text="Update" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Update</asp:LinkButton>
                            <asp:LinkButton ID="lbtnCancelCityTab" runat="server" CommandName="CancelCompoent" 
                                ValidationGroup="cancel"  CausesValidation="false"
                                Text="Cancel" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Cancel</asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton5" runat="server" CommandName="Edit"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex")%>'>
                                <asp:Image ID="ibtnEdit" runat="server" ImageUrl="assets/b_edit.png"/></asp:LinkButton>
                            <asp:LinkButton ID="LinkButton6" runat="server" CommandName="Delete"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>
                                <asp:Image ID="ibtnDelete" runat="server" ImageUrl="assets/action_delete.png"/></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label3" runat="server" Text="Display: ">Display:</asp:Label>
            <asp:DropDownList ID="ddlPageSizeCity" runat="server" AutoPostBack="true">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div id="tab4">
            <fieldset>
                <h2>Add a new district</h2>
                    <div class="input_field"><label>Country:</label>
                    <asp:DropDownList ID="ddlCountryForDistrict" runat="server" Width="215px" AutoPostBack="true" OnSelectedIndexChanged="ddlCountryForDistrict_SelectedIndexChanged">

                    </asp:DropDownList></div>
                    <div class="input_field"><label>Region:</label>
                    <asp:DropDownList ID="ddlRegionForDistrict" runat="server" Width="215px" AutoPostBack="false">
                    </asp:DropDownList></div>
                    <div class="input_field"><label>City:</label>
                    <asp:DropDownList ID="ddlCity" runat="server" Width="215px" AutoPostBack="false">
                    </asp:DropDownList></div>
                <div class="input_field">
                    <label>District name:</label>
                    <asp:TextBox ID="txtDistrict" runat="server"></asp:TextBox>
                </div>
                <div class="input_field no_margin_bottom">
                    <label>&nbsp;</label>
                    <asp:Button ID="btnAddDistrict" runat="server" Text="ADD" CssClass="submit" />
                    <input class="submit" type="reset" value="RESET" />
                </div>
            </fieldset>
            <h2>Districts List</h2>
            <asp:GridView ID="grvDistrict" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataKeyNames="DistrictId" PageSize="5" OnRowCancelingEdit="grvDistrict_RowCancelingEdit" OnRowCommand="grvDistrict_RowCommand" OnRowDataBound="grvDistrict_RowDataBound" OnRowDeleting="grvDistrict_RowDeleting" OnRowEditing="grvDistrict_RowEditing" OnRowUpdating="grvDistrict_RowUpdating" Width="100%">
            <HeaderStyle CssClass="header_gridview"/>
            <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="Id">
                        <ItemTemplate>
                            <%#Eval ("DistrictId") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="District Name">
                        <ItemTemplate>
                            <%#Eval ("DistrictName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="extxtDistrictName" runat="server" Text='<%# Bind("DistrictName")%>' Visible="true"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="City Name">
                        <ItemTemplate>
                            <%# Eval("CityName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="extddlCityName" runat="server" DataTextField="CityName" DataValueField="CityId"></asp:DropDownList>
                        </EditItemTemplate>
                        
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Actions"> 
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbtnUpdateDistrictTab" runat="server" CommandName="UpdateComponent" 
                                ValidationGroup="update" CausesValidation="True"
                                Text="Update" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Update</asp:LinkButton>
                            <asp:LinkButton ID="lbtnCancelDistrictTab" runat="server" CommandName="CancelCompoent" 
                                ValidationGroup="cancel"  CausesValidation="false"
                                Text="Cancel" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>Cancel</asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton7" runat="server" CommandName="Edit"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex")%>'>
                                <asp:Image ID="ibtnEdit" runat="server" ImageUrl="assets/b_edit.png"/></asp:LinkButton>
                            <asp:LinkButton ID="LinkButton8" runat="server" CommandName="Delete"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>
                                <asp:Image ID="ibtnDelete" runat="server" ImageUrl="assets/action_delete.png"/></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label4" runat="server" Text="Display: ">Display:</asp:Label>
            <asp:DropDownList ID="ddlPageSizeDistrict" runat="server" AutoPostBack="true">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
        </div>
    </div>
</asp:Content>
